package work.xkong.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @PACKAGE_NAME: work.xkong.vo.outputvo
 * @NAME: ResponseRest
 * @USER: NuanYang
 * @create: 2022/11/21 21:37
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResponseRest<T> {
    private int code;
    private String msg;
    private T data;

    public static <T> ResponseRest<T> creatSuccess() {
        return new ResponseRest<T>(ResponseCode.SUCCESS.getCode(), ResponseCode.SUCCESS.getMsg());
    }

    public static <T> ResponseRest<T> creatSuccess(String msg) {
        return new ResponseRest<T>(ResponseCode.SUCCESS.getCode(), msg);
    }

    public static <T> ResponseRest<T> creatSuccess(T data) {
        return new ResponseRest<T>(ResponseCode.SUCCESS.getCode(), ResponseCode.SUCCESS.getMsg(), data);
    }

    public static <T> ResponseRest<T> creatSuccess(String msg, T data) {
        return new ResponseRest<T>(ResponseCode.SUCCESS.getCode(), msg, data);
    }

    public static <T> ResponseRest<T> creatFail() {
        return new ResponseRest<T>(ResponseCode.FAIL.getCode(), ResponseCode.FAIL.getMsg());
    }

    public static <T> ResponseRest<T> creatFail(String msg) {
        return new ResponseRest<T>(ResponseCode.FAIL.getCode(), msg);
    }

    public static <T> ResponseRest<T> creatFail(T data) {
        return new ResponseRest<T>(ResponseCode.FAIL.getCode(), ResponseCode.FAIL.getMsg(), data);
    }

    public static <T> ResponseRest<T> creatFail(String msg, T data) {
        return new ResponseRest<T>(ResponseCode.FAIL.getCode(), msg, data);
    }

    public static <T> ResponseRest<T> creatFail(int code, String msg) {
        return new ResponseRest<T>(code, msg);
    }

    public static <T> ResponseRest<T> creatResult(int code, String msg, T data) {
        return new ResponseRest<T>(code, msg, data);
    }


    public ResponseRest(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ResponseRest(String msg, T data) {
        this.msg = msg;
        this.data = data;
    }

    public ResponseRest(int code, T data) {
        this.code = code;
        this.data = data;
    }

    public ResponseRest(int code) {
        this.code = code;
    }

    public ResponseRest(String msg) {
        this.msg = msg;
    }

    public ResponseRest(T data) {
        this.data = data;
    }
}
